package com.ceac.kronos.ejb.entitybeans;

import com.ceac.kronos.ejb.entitybeans.Participant;

import java.io.Serializable;

import java.sql.Timestamp;

import java.util.List;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.SequenceGenerator;
import javax.persistence.Table;
import javax.persistence.TableGenerator;

@Entity
@NamedQueries( { @NamedQuery(name = "Person.findAll", query = "select o from Person o"),
        @NamedQuery(name = "Person.findByIdCard", query = "select o from Person o where o.idCard = :idCard") })
@Table(name = "PERSONS")
public class Person implements Serializable {
    private String address;
    private String alias;
    @Column(name="BIRTH_DATE")
    private Timestamp birthDate;
    @Column(name="CELL_PHONE")
    private String cellPhone;
    private String city;
    private String comments;
    private String county;
    @Column(name="CREATED_BY")
    private Integer createdBy;
    @Column(name="CREATION_DATE")
    private Timestamp creationDate;
    @Column(name="EMAIL_ADDRESS")
    private String emailAddress;
    @Column(name="END_ACTIVE_DATE")
    private Timestamp endActiveDate;
    private String fax;
    @Column(name="ID_CARD")
    private String idCard;
    @Column(name="ISO_COUNTRY")
    private String isoCountry;
    @Column(name="LAST_UPDATED_BY")
    private Integer lastUpdatedBy;
    @Column(name="LAST_UPDATE_DATE")
    private Timestamp lastUpdateDate;
    @Column(name="MIDDLE_NAME")
    private String middleName;
    @Column(nullable = false)
    private String name;
    @Id
    @Column(name="PERSON_ID", nullable = false)
    @TableGenerator(name="personsSequence", table="SEQUENCES",
        schema = "kronos", initialValue = 1, allocationSize = 1,
                    pkColumnName = "SEQUENCE_NAME", valueColumnName = "SEQUENCE_COUNT", pkColumnValue="DEFAULT")
    @GeneratedValue(generator = "personsSequence", strategy = GenerationType.TABLE)
    private Integer personId;
    @Column(name="PHONE_NUMBER")
    private String phoneNumber;
    @Column(name="POSTAL_CODE")
    private String postalCode;
    private String province;
    @Column(name="START_ACTIVE_DATE")
    private Timestamp startActiveDate;
    private String surname;
    private String title;

    @OneToMany(targetEntity = Participant.class, mappedBy = "person", fetch = FetchType.LAZY)
    private List<Participant> participations;
    
    public Person() {
    }

    public Person(String address, String alias, Timestamp birthDate,
                  String cellPhone, String city, String comments,
                  String county, Integer createdBy, Timestamp creationDate,
                  String emailAddress, Timestamp endActiveDate, String fax,
                  String idCard, String isoCountry, Timestamp lastUpdateDate,
                  Integer lastUpdatedBy, String middleName, String name,
                  Integer personId, String phoneNumber, String postalCode,
                  String province, Timestamp startActiveDate, String surname,
                  String title) {
        this.address = address;
        this.alias = alias;
        this.birthDate = birthDate;
        this.cellPhone = cellPhone;
        this.city = city;
        this.comments = comments;
        this.county = county;
        this.createdBy = createdBy;
        this.creationDate = creationDate;
        this.emailAddress = emailAddress;
        this.endActiveDate = endActiveDate;
        this.fax = fax;
        this.idCard = idCard;
        this.isoCountry = isoCountry;
        this.lastUpdateDate = lastUpdateDate;
        this.lastUpdatedBy = lastUpdatedBy;
        this.middleName = middleName;
        this.name = name;
        this.personId = personId;
        this.phoneNumber = phoneNumber;
        this.postalCode = postalCode;
        this.province = province;
        this.startActiveDate = startActiveDate;
        this.surname = surname;
        this.title = title;
    }

    public String getAddress() {
        return address;
    }

    public void setAddress(String address) {
        this.address = address;
    }

    public String getAlias() {
        return alias;
    }

    public void setAlias(String alias) {
        this.alias = alias;
    }

    public Timestamp getBirthDate() {
        return birthDate;
    }

    public void setBirthDate(Timestamp birthDate) {
        this.birthDate = birthDate;
    }

    public String getCellPhone() {
        return cellPhone;
    }

    public void setCellPhone(String cellPhone) {
        this.cellPhone = cellPhone;
    }

    public String getCity() {
        return city;
    }

    public void setCity(String city) {
        this.city = city;
    }

    public String getComments() {
        return comments;
    }

    public void setComments(String comments) {
        this.comments = comments;
    }

    public String getCounty() {
        return county;
    }

    public void setCounty(String county) {
        this.county = county;
    }

    public Integer getCreatedBy() {
        return createdBy;
    }

    public void setCreatedBy(Integer createdBy) {
        this.createdBy = createdBy;
    }

    public Timestamp getCreationDate() {
        return creationDate;
    }

    public void setCreationDate(Timestamp creationDate) {
        this.creationDate = creationDate;
    }

    public String getEmailAddress() {
        return emailAddress;
    }

    public void setEmailAddress(String emailAddress) {
        this.emailAddress = emailAddress;
    }

    public Timestamp getEndActiveDate() {
        return endActiveDate;
    }

    public void setEndActiveDate(Timestamp endActiveDate) {
        this.endActiveDate = endActiveDate;
    }

    public String getFax() {
        return fax;
    }

    public void setFax(String fax) {
        this.fax = fax;
    }

    public String getIdCard() {
        return idCard;
    }

    public void setIdCard(String idCard) {
        this.idCard = idCard;
    }

    public String getIsoCountry() {
        return isoCountry;
    }

    public void setIsoCountry(String isoCountry) {
        this.isoCountry = isoCountry;
    }

    public Integer getLastUpdatedBy() {
        return lastUpdatedBy;
    }

    public void setLastUpdatedBy(Integer lastUpdatedBy) {
        this.lastUpdatedBy = lastUpdatedBy;
    }

    public Timestamp getLastUpdateDate() {
        return lastUpdateDate;
    }

    public void setLastUpdateDate(Timestamp lastUpdateDate) {
        this.lastUpdateDate = lastUpdateDate;
    }

    public String getMiddleName() {
        return middleName;
    }

    public void setMiddleName(String middleName) {
        this.middleName = middleName;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public Integer getPersonId() {
        return personId;
    }

    public void setPersonId(Integer personId) {
        this.personId = personId;
    }

    public String getPhoneNumber() {
        return phoneNumber;
    }

    public void setPhoneNumber(String phoneNumber) {
        this.phoneNumber = phoneNumber;
    }

    public String getPostalCode() {
        return postalCode;
    }

    public void setPostalCode(String postalCode) {
        this.postalCode = postalCode;
    }

    public String getProvince() {
        return province;
    }

    public void setProvince(String province) {
        this.province = province;
    }

    public Timestamp getStartActiveDate() {
        return startActiveDate;
    }

    public void setStartActiveDate(Timestamp startActiveDate) {
        this.startActiveDate = startActiveDate;
    }

    public String getSurname() {
        return surname;
    }

    public void setSurname(String surname) {
        this.surname = surname;
    }

    public String getTitle() {
        return title;
    }

    public void setTitle(String title) {
        this.title = title;
    }

    public void setParticipations(List<Participant> participations) {
        this.participations = participations;
    }

    public List<Participant> getParticipations() {
        return participations;
    }
}
